const http = require('http')
const server = http.createServer()
server.on('request', (req, res) => {
  const url = req.url
  let defaultContent = `<h1>404 not found</h1>`
  if (url === '/' || url === '/index.html') {
    defaultContent = `<h1>欢迎来到首页</h1>`
  } else if (url === '/about.html') {
    defaultContent = `<h1>欢迎来到关于页面</h1>`
  }
  res.setHeader('Content-Type', 'text/html;charset=utf-8')
  res.end(defaultContent)
})
server.listen(8089, () => {
  console.log('服务器已启动，请访问http://127.0.0.1:8089');
})